package com.io.output;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;

import com.io.input.BufferedInputFile;

public class BasicFileOutput {

	static String file = "F:/BufferedInputFile.java";

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(
				new StringReader(
						BufferedInputFile
								.read("F:/workspace_luna/demo_thinkinjava/src/com/io/input/BufferedInputFile.java")));

		// BufferedWriter缓冲输出
		// PrintWriter提供格式化输出
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				file)));

		int lineCount = 1;
		String s;
		while ((s = in.readLine()) != null) {
			out.println(lineCount++ + ":" + s);
		}
		out.close();

		System.out.println(BufferedInputFile.read(file));
	}

}
